/**
 * Created by cuppi on 2016/11/25.
 */
class ConvertTool {

  static cityFromNetCity(city) {
    return {
      id: city.id,
      name: city.city_name,
      address: city.formatAddress
    };
  }

  static safetyArray(array) {
    return (array || []);
  }

  static emptyObjectFromArray(array, index) {
    if (array && array[index]) {
      return array[index];
    }
    return {};
  }

  static safetyObjectFromArray(array, index) {
    if (array && array[index]) {
      return array[index];
    }
    return null;
  }

  static emptyObjectAttribute(object, attribute) {
    if (object && object.hasOwnProperty(attribute)) {
      return object[attribute];
    }
    return {};
  }

  static safetyObjectAttribute(object, attribute) {
    if (object && object.hasOwnProperty(attribute)) {
      return object[attribute];
    }
    return null;
  }
}

export default ConvertTool;
